home *** CD-ROM | disk | FTP | other *** search
- Path: gail.ripco.com!mambuhl
- From: mambuhl@ripco.com (Martin Ambuhl)
- Newsgroups: comp.lang.c
- Subject: newbie question concernin
- Date: 19 Feb 1996 18:53:53 GMT
- Organization: Ripco Communications, Inc.
- Message-ID: <4gah01$6cc@gail.ripco.com>
- NNTP-Posting-Host: foley.ripco.com
-
- rblayney@extro.ucc.su.OZ.AU (Robert Blayney)
- in <rblayney.824643669@extro> asks:
-
- > I'm attempting to use the following function call
- > fread(&result, sizeof(int), 16, fp);
-
- If you have declared
- int result[16];
- could change the above to:
- fread(result, sizeof(int), 16, fp);
-
- > Unfortunately when I attempt to print the contents of the result array
- >I obtain all zeros, where result is declared: int *result. I've tried success
- >ully
-
- In which case there is no space allocated for result. Try adding:
- #include <stdlib.h>
- #define RESLTS_NUM 16
- /* .... */
- int *result;
- /* ... */
- if (!(result = malloc(RESLTS_NUM * sizeof *result)))
- /* error handling */;
- fread(result, sizeof(int), 16, fp);
- at the appropriate place.
-
-
- --
- * Martin Ambuhl net: mambuhl@ripco.com
- * Chicago, IL (USA)
-